/**
 * Created by Delicate on 2017/5/31.
 */
let layer,$;
require(['jquery', 'common', 'validate', 'layer'], function (a,b,c,d) {
    $ = a;
    layer = d;
    init();
    monitor();
    service();
})
const init = () => {
    if(top != self){
        top.location.href = location.href;
    }
}
const monitor = () => {

}
const service = () => {

}
const submit = obj => {
    const username = $("#mobile").val().trim();
    const password = $("#password").val().trim();
    // const returnUrl = $(obj).data("url");
    if (!$valid.phone(username)) {
        return layer.msg("请输入11位合法用户名!");
    }
    if (!$valid.password(password)) {
        return layer.msg("请输入6-32位合法密码!");
    }
    const data = {
        mobile: username,
        password: password
    }
    $.ajax({
        url: ctx+"/login/doLogin"
        , type: "post"
        , data: data
        , dataType: "json"
        , success: data => {
            if (data.isOk) {
                if (data.returnUrl.length > 0) {
                    location.href = ctx + data.returnUrl;
                } else {
                    location.href = ctx+"/platform";
                }
            } else {
                layer.alert(data.msg);
            }
        }
    })
}